package com.wman.sheep.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wman.sheep.R;

public class BaseTitleBar extends RelativeLayout {
    public TextView left1;
    public TextView right1;
    public TextView right2;
    public TextView title;
    public TextView left_back;
    public ImageView btn_img_right_1;
    public ImageView btn_img_right_2;
    public ImageView btn_img_left_1;

    public BaseTitleBar(Context context) {
        super(context);
    }

    public BaseTitleBar(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public BaseTitleBar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        init();
    }

    public void init() {
        left1 = (TextView) findViewById(R.id.btn_left_1);
        right1 = (TextView) findViewById(R.id.btn_right_1);
        right2 = (TextView) findViewById(R.id.btn_right_2);
        title = (TextView) findViewById(R.id.txt_title);
        left_back = (TextView) findViewById(R.id.btn_left_back);
        btn_img_left_1 = (ImageView) findViewById(R.id.btn_img_left_1);
        btn_img_right_1 = (ImageView) findViewById(R.id.btn_img_right_1);
        btn_img_right_2 = (ImageView) findViewById(R.id.btn_img_right_2);
    }

    public void setLeftBackButton(String lable, OnClickListener clickListener) {
        left_back.setText(lable);
        left_back.setOnClickListener(clickListener);
        left_back.setVisibility(View.VISIBLE);
    }

    public void setLeft1Button(String lable, OnClickListener clickListener) {
        left1.setText(lable);
        left1.setOnClickListener(clickListener);
        left1.setVisibility(View.VISIBLE);
    }

    public void setRight1Button(String lable, OnClickListener clickListener) {
        right1.setText(lable);
        right1.setOnClickListener(clickListener);
        right1.setVisibility(View.VISIBLE);
    }

    public void setRight2Button(String lable, OnClickListener clickListener) {
        right2.setText(lable);
        right2.setOnClickListener(clickListener);
        right2.setVisibility(View.VISIBLE);
    }

    public void setRightIcon1Button(int res, OnClickListener clickListener) {
        btn_img_right_1.setImageResource(res);
        btn_img_right_1.setOnClickListener(clickListener);
        btn_img_right_1.setVisibility(View.VISIBLE);
    }

    public void setLeftIcon1Button(int res, OnClickListener clickListener) {
        btn_img_left_1.setImageResource(res);
        btn_img_left_1.setOnClickListener(clickListener);
        btn_img_left_1.setVisibility(View.VISIBLE);
    }

    public void setRightIcon2Button(int res, OnClickListener clickListener) {
        btn_img_right_2.setImageResource(res);
        btn_img_right_2.setOnClickListener(clickListener);
        btn_img_right_2.setVisibility(View.VISIBLE);
    }

    public void setCenterTitle(String lable) {
        title.setText(lable);
        title.setVisibility(View.VISIBLE);
    }

    public void reset() {
        left1.setText("");
        right1.setText("");
        right2.setText("");
        title.setText("");

        left1.setVisibility(View.GONE);
        right1.setVisibility(View.GONE);
        right2.setVisibility(View.GONE);
        title.setVisibility(View.GONE);
        btn_img_right_1.setVisibility(View.GONE);
        btn_img_right_2.setVisibility(View.GONE);
    }
}
